package com.menhai.personmanagement.controller;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.menhai.personmanagement.entity.PersonnelStatistics;
import com.menhai.personmanagement.entity.co.PersonnelStatisticsCo;
import com.menhai.personmanagement.services.PersonnelStatisticsService;
import com.menhai.personmanagement.utils.ExportSysPersonnelStatisticsInfoExcel;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@RestController
@RequestMapping("/PersonnelStatistics")
public class PersonnelStatisticsController {
	@Autowired
	private PersonnelStatisticsService PersonnelStatisticsService;
	
	/*@RequestMapping("/selectQuery")
	public List<PersonnelStatistics> selectQuery (PersonnelStatistics PersonnelStatistics){
		List<PersonnelStatistics> PersonnelStatisticsList = new ArrayList<PersonnelStatistics>();
		PersonnelStatisticsList = PersonnelStatisticsService.selectQuery(PersonnelStatistics);
        return PersonnelStatisticsList;
   }*/
	
	@RequestMapping("/selectQuery")
    public IPage<PersonnelStatistics> login(PersonnelStatisticsCo PersonnelStatistics){
        IPage<PersonnelStatistics> IPage = PersonnelStatisticsService.selectQuery(PersonnelStatistics);
        return IPage;
    }
	
	@GetMapping("/export")
    public void exports(HttpServletResponse response,PersonnelStatistics PersonnelStatistics){
        try {
            List<PersonnelStatistics> list = PersonnelStatisticsService.selectQueryExcel(PersonnelStatistics);
            ServletOutputStream out = response.getOutputStream();
            new ExportSysPersonnelStatisticsInfoExcel().export(list, out, response);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
